<?php
include REPOMATH_ROOT . '/util/SQL.class.php';

class DBUtil {
	var $sql;

	function DBUtil() {
		$this->sql = new SQL();
	}

	private function DoConnect() {
		$this->sql->Connect("localhost", "root", "rootroot", "repomath");
	}

	private function DisConnect() {
		$this->sql->Close();
	}

	function ExQueryGetRes($queryStr) {
		$this->DoConnect();
		$res = $this->sql->Query($queryStr);
		$this->DisConnect();
		return $res;
	}

	function ExQueryGetArray($queryStr) {
		$this->DoConnect();
		$res = $this->sql->Query($queryStr);
		$this->DisConnect();
		$rowsnum = $this->sql->getRowsNum($res);
		if ($rowsnum > 0) {
			$rows = $this->sql->getArray($res);
			return $rows;
		} else {
			return false;
		}

	}
	
	function ExQueryGetRows($queryStr) {
		$this->DoConnect();
		$res = $this->sql->Query($queryStr);
		$this->DisConnect();
		$rowsnum = $this->sql->getRowsNum($res);
		if ($rowsnum > 0) {
			$rows = $this->sql->getRows($res);
			return $rows;
		} else {
			return false;
		}

	}

}
?>